import { pubRequire } from '@utils/public'
const baseUrl = '/roles'
/* 角色列表 */
export function getSearchList(obj, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}`, obj, callbBack, errBack)
}
/* 停用 */
export function disable(id, callbBack, errBack) {
  return pubRequire('put', `${baseUrl}/${id}/disable`, '', callbBack, errBack)
}
/* 启用 */
export function enable(id, callbBack, errBack) {
  return pubRequire('put', `${baseUrl}/${id}/enable`, '', callbBack, errBack)
}
/* 删除*/
export function deleteReq(obj, callbBack, errBack) {
  return pubRequire('delete', `${baseUrl}`, obj, callbBack, errBack)
}
/* 获取部门信息树状结构 */
export function getTreeList(obj, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}/depts`, obj, callbBack, errBack)
}
/*数据权限获取表单详情*/
export function getForm(roleId, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}/${roleId}`, '', callbBack, errBack)
}
/*数据权限表单提交*/
export function dataAuthor(roleId, obj, callbBack, errBack) {
  return pubRequire(
    'put',
    `${baseUrl}/${roleId}/permissions`,
    obj,
    callbBack,
    errBack
  )
}
/*分配用户获取列表*/
export function setUserList(roleId, obj, callbBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/${roleId}/contain`,
    obj,
    callbBack,
    errBack
  )
}
/*取消授权*/
export function batchCanAuthor(roleId, obj, callbBack, errBack) {
  return pubRequire('delete', `/roles/${roleId}/users`, obj, callbBack, errBack)
}
/*分配用户弹窗获取列表*/
export function assigningUsers(roleId, obj, callbBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/${roleId}/uncontain`,
    obj,
    callbBack,
    errBack
  )
}
/*分配用户提交表单*/
export function subUsers(roleId, obj, callbBack, errBack) {
  return pubRequire('post', `/roles/${roleId}/users`, obj, callbBack, errBack)
}
/* 校验角色权限 */
export function roleKey(id, obj, callbBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/${id}/verification`,
    obj,
    callbBack,
    errBack
  )
}
/* 校验角色名称 */
export function roleName(id, obj, callbBack, errBack) {
  return pubRequire(
    'get',
    `${baseUrl}/${id}/verification`,
    obj,
    callbBack,
    errBack
  )
}
/* 编辑时获取表单详情 */
export function editFormData(roleId, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}/${roleId}`, roleId, callbBack, errBack)
}
/* 编辑时获取部门信息树状结构 */
export function editGetTree(obj, callbBack, errBack) {
  return pubRequire('get', `${baseUrl}/menus`, obj, callbBack, errBack)
}
/*新增表单提交*/
export function addRole(obj, callbBack, errBack) {
  return pubRequire('post', `${baseUrl}`, obj, callbBack, errBack)
}
/*编辑表单提交*/
export function editRole(obj, callbBack, errBack) {
  return pubRequire('put', `${baseUrl}`, obj, callbBack, errBack)
}
